//
//  FYBaseListPage.m
//  ThePainter
//
//  Created by Sean on 15/8/12.
//  Copyright (c) 2015年 FeiYu. All rights reserved.
//

#import "FYBaseListPage.h"

@interface FYBaseListPage ()

- (void)initRefreshHeader;

- (void)initRefreshFoot;

@end

@implementation FYBaseListPage

- (void)viewDidLoad {
    [super viewDidLoad];
    
    //去掉分隔线
    self.tableView.separatorStyle = UITableViewCellSelectionStyleNone;
    self.tableView.backgroundColor = fyColorLightGary;
    
    [self initRefreshHeader];
    [self initRefreshFoot];
}


- (void)initRefreshHeader {
    
    NSArray *idleImages = @[[UIImage imageNamed:@"loading_1"]];
    NSArray *pullingImages = @[[UIImage imageNamed:@"loading_1"],
                               [UIImage imageNamed:@"loading_2"],
                               [UIImage imageNamed:@"loading_3"],
                               [UIImage imageNamed:@"loading_4"]];
    NSArray *refreshingImages = pullingImages;
    
    //下拉刷新
    // 设置回调（一旦进入刷新状态，就调用target的action，也就是调用self的loadNewData方法）
    MJRefreshGifHeader *header = [MJRefreshGifHeader headerWithRefreshingTarget:self refreshingAction:@selector(loadNewData)];
    // 设置普通状态的动画图片
    [header setImages:idleImages forState:MJRefreshStateIdle];
    // 设置即将刷新状态的动画图片（一松开就会刷新的状态）
    [header setImages:pullingImages forState:MJRefreshStatePulling];
    // 设置正在刷新状态的动画图片
    [header setImages:refreshingImages forState:MJRefreshStateRefreshing];
    // 隐藏时间
    header.lastUpdatedTimeLabel.hidden = YES;
    // 隐藏状态
    header.stateLabel.hidden = YES;
    // 设置header
    self.tableView.header = header;
}

- (void)initRefreshFoot {
    
    NSArray *refreshingImages = @[[UIImage imageNamed:@"loading_1"],
                                  [UIImage imageNamed:@"loading_2"],
                                  [UIImage imageNamed:@"loading_3"],
                                  [UIImage imageNamed:@"loading_4"]];
    // 设置回调（一旦进入刷新状态，就调用target的action，也就是调用self的loadMoreData方法）
    MJRefreshAutoGifFooter *footer = [MJRefreshAutoGifFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];
    // 设置刷新图片
    [footer setImages:refreshingImages forState:MJRefreshStateRefreshing];
    // 设置尾部
    self.tableView.footer = footer;
}

- (void)loadNewData {
    
}

- (void)loadMoreData {
    
}

- (void)finishLoadNewData {
    [self.tableView.header endRefreshing];
}

- (void)finishLoadMoreData {
    [self.tableView.footer endRefreshing];
}

- (void)noMoreData {
    [self.tableView.footer noticeNoMoreData];
}

- (void)resetNoMore {
    [self.tableView.footer resetNoMoreData];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
